package com.zookeeper.zkclient;

import com.github.zkclient.*;
import org.apache.zookeeper.*;

import java.util.List;
import java.util.concurrent.CountDownLatch;

/**
 * @Author : hebad90@163.com
 * @Date : 2014/11/20 22:10
 * @From : javalearn
 */
public class Test{
    public static void main(String[] args) throws Exception{
        ZooKeeper zooKeeper = new ZooKeeper("jiejiaoo.com:2181", 5000, new Watcher() {
            public void process(WatchedEvent watchedEvent) {
                System.out.println("path="+watchedEvent.getPath()+",state="+watchedEvent.getState()+",type="+watchedEvent.getType());
            }
        });
        while(true){
            String now = ""+System.currentTimeMillis();
            String rs = zooKeeper.create("/"+now,now.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
            System.out.println(rs);
            Thread.sleep(2000);
        }
    }

}
